package cate.game.play.buff.h;

import cate.common.table.d.GDBuff;
import cate.game.play.buff.Buff;
import cate.game.play.buff.BuffHandler;
import cate.game.play.proce.action.ctx.ActionCtx;

/**
 * 觉醒值无法增长且无法进入觉醒状态,若处于觉醒状态则失效1回合
 */
public class 觉醒失效BH extends BuffHandler {

	@Override
	public void onAdd(ActionCtx action) {
		Buff oneByType = buff.owner.buff.findOneByType(GDBuff.Type.英雄觉醒);
		if (oneByType == null) {
			return;
		}
		roundRemove = oneByType.roundRemove;
		oneByType.markInvalid(action);
	}

	private Integer roundRemove;

	@Override
	public void onInvalid(ActionCtx action, byte invalidReason) {
		if (roundRemove == null || roundRemove <= 0) {
			return;
		}
		int cd = roundRemove - action.getRound().index;
		if (cd > 0) {
			buff.owner.skill.doAwaken(action, cd);
		}
	}
}
